<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>2.5. HTML &mdash; Pyslet 0.4.20140526 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '0.4.20140526',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Pyslet 0.4.20140526 documentation" href="index.html" />
    <link rel="up" title="2. Supporting Standards" href="general.html" />
    <link rel="next" title="2.6. Uniform Resource Identifiers (RFC2396)" href="rfc2396.html" />
    <link rel="prev" title="2.4. XML Schema Datatypes" href="xsdatatypes20041028.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="rfc2396.html" title="2.6. Uniform Resource Identifiers (RFC2396)"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="xsdatatypes20041028.html" title="2.4. XML Schema Datatypes"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Pyslet 0.4.20140526 documentation</a> &raquo;</li>
          <li><a href="general.html" accesskey="U">2. Supporting Standards</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyslet.html40_19991224">
<span id="html"></span><h1>2.5. HTML<a class="headerlink" href="#module-pyslet.html40_19991224" title="Permalink to this headline">¶</a></h1>
<p>This module defines functions and classes for working with HTML documents.  The
version of the standard implemented is, loosely speaking, the HTML 4.0.1
Specification: <a class="reference external" href="http://www.w3.org/TR/html401/">http://www.w3.org/TR/html401/</a></p>
<p>This module contains code that can help parse HTML documents into classes based
on the basic <tt class="xref py py-mod docutils literal"><span class="pre">xml20081126</span></tt> XML module, acting as a gateway to XHTML.</p>
<p>This module also exposes a number of internal functions typically defined
privately in HTML parser implementations which make it easier to reuse concepts
from HTML in other modules.  For example, the <a class="reference internal" href="#pyslet.html40_19991224.LengthType" title="pyslet.html40_19991224.LengthType"><tt class="xref py py-class docutils literal"><span class="pre">LengthType</span></tt></a> used for
storing HTML lengths (which can be pixel or relative) is used extensively by
<tt class="xref py py-mod docutils literal"><span class="pre">imsqtiv2p1</span></tt>.</p>
<dl class="data">
<dt id="pyslet.html40_19991224.HTML40_PUBLICID">
<tt class="descclassname">pyslet.html40_19991224.</tt><tt class="descname">HTML40_PUBLICID</tt><a class="headerlink" href="#pyslet.html40_19991224.HTML40_PUBLICID" title="Permalink to this definition">¶</a></dt>
<dd><p>The public ID to use in the declaration of an HTML document</p>
</dd></dl>

<dl class="data">
<dt id="pyslet.html40_19991224.XHTML_NAMESPACE">
<tt class="descclassname">pyslet.html40_19991224.</tt><tt class="descname">XHTML_NAMESPACE</tt><a class="headerlink" href="#pyslet.html40_19991224.XHTML_NAMESPACE" title="Permalink to this definition">¶</a></dt>
<dd><p>The namespace to use in the delcaration of an XHTML document</p>
</dd></dl>

<div class="section" id="x-html-documents">
<h2>2.5.1. (X)HTML Documents<a class="headerlink" href="#x-html-documents" title="Permalink to this headline">¶</a></h2>
<p>This module contains an experimental class for working with HTML documents.  At
the time of writing the implementation is designed to provide just enough HTML
parsing to support the use of HTML within other standards (such as Atom and
QTI).</p>
<dl class="class">
<dt id="pyslet.html40_19991224.XHTMLDocument">
<em class="property">class </em><tt class="descclassname">pyslet.html40_19991224.</tt><tt class="descname">XHTMLDocument</tt><big>(</big><em>**args</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.XHTMLDocument" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">pyslet.xmlnames20091208.XMLNSDocument</span></tt></p>
<p>Represents an HTML document.</p>
<p>Although HTML documents are not always represented using XML they can be,
and therefore we base our implementation on the
<tt class="xref py py-class docutils literal"><span class="pre">pyslet.xmlnames20091208.XMLNSDocument</span></tt> class - a namespace-aware
variant of the basic <tt class="xref py py-class docutils literal"><span class="pre">pyslet.xml20081126.XMLDocument</span></tt> class.</p>
<dl class="attribute">
<dt id="pyslet.html40_19991224.XHTMLDocument.classMap">
<tt class="descname">classMap</tt><em class="property"> = {('http://www.w3.org/1999/xhtml', 'dl'): &lt;class 'pyslet.html40_19991224.DL'&gt;, ('http://www.w3.org/1999/xhtml', 'ins'): &lt;class 'pyslet.html40_19991224.Ins'&gt;, ('http://www.w3.org/1999/xhtml', 'optgroup'): &lt;class 'pyslet.html40_19991224.OptGroup'&gt;, ('http://www.w3.org/1999/xhtml', 'thead'): &lt;class 'pyslet.html40_19991224.THead'&gt;, ('http://www.w3.org/1999/xhtml', 'var'): &lt;class 'pyslet.html40_19991224.Var'&gt;, ('http://www.w3.org/1999/xhtml', 'h2'): &lt;class 'pyslet.html40_19991224.H2'&gt;, ('http://www.w3.org/1999/xhtml', 'frameset'): &lt;class 'pyslet.html40_19991224.Frameset'&gt;, ('http://www.w3.org/1999/xhtml', 'acronym'): &lt;class 'pyslet.html40_19991224.Acronym'&gt;, ('http://www.w3.org/1999/xhtml', 'br'): &lt;class 'pyslet.html40_19991224.Br'&gt;, ('http://www.w3.org/1999/xhtml', 'param'): &lt;class 'pyslet.html40_19991224.Param'&gt;, ('http://www.w3.org/1999/xhtml', 'input'): &lt;class 'pyslet.html40_19991224.Input'&gt;, ('http://www.w3.org/1999/xhtml', 'fieldset'): &lt;class 'pyslet.html40_19991224.FieldSet'&gt;, ('http://www.w3.org/1999/xhtml', 'basefont'): &lt;class 'pyslet.html40_19991224.BaseFont'&gt;, ('http://www.w3.org/1999/xhtml', 'u'): &lt;class 'pyslet.html40_19991224.U'&gt;, ('http://www.w3.org/1999/xhtml', 'strong'): &lt;class 'pyslet.html40_19991224.Strong'&gt;, ('http://www.w3.org/1999/xhtml', 'noscript'): &lt;class 'pyslet.html40_19991224.NoScript'&gt;, ('http://www.w3.org/1999/xhtml', 'small'): &lt;class 'pyslet.html40_19991224.Small'&gt;, ('http://www.w3.org/1999/xhtml', 'caption'): &lt;class 'pyslet.html40_19991224.Caption'&gt;, ('http://www.w3.org/1999/xhtml', 'sup'): &lt;class 'pyslet.html40_19991224.Sup'&gt;, ('http://www.w3.org/1999/xhtml', 'big'): &lt;class 'pyslet.html40_19991224.Big'&gt;, ('http://www.w3.org/1999/xhtml', 'em'): &lt;class 'pyslet.html40_19991224.Em'&gt;, ('http://www.w3.org/1999/xhtml', 'form'): &lt;class 'pyslet.html40_19991224.Form'&gt;, ('http://www.w3.org/1999/xhtml', 'meta'): &lt;class 'pyslet.html40_19991224.Meta'&gt;, ('http://www.w3.org/1999/xhtml', 'blockquote'): &lt;class 'pyslet.html40_19991224.Blockquote'&gt;, ('http://www.w3.org/1999/xhtml', 'a'): &lt;class 'pyslet.html40_19991224.A'&gt;, ('http://www.w3.org/1999/xhtml', 'strike'): &lt;class 'pyslet.html40_19991224.Strike'&gt;, ('http://www.w3.org/1999/xhtml', 'legend'): &lt;class 'pyslet.html40_19991224.Legend'&gt;, ('http://www.w3.org/1999/xhtml', 'tt'): &lt;class 'pyslet.html40_19991224.TT'&gt;, ('http://www.w3.org/1999/xhtml', 'h3'): &lt;class 'pyslet.html40_19991224.H3'&gt;, ('http://www.w3.org/1999/xhtml', 'area'): &lt;class 'pyslet.html40_19991224.Area'&gt;, ('http://www.w3.org/1999/xhtml', 'tfoot'): &lt;class 'pyslet.html40_19991224.TFoot'&gt;, ('http://www.w3.org/1999/xhtml', 'script'): &lt;class 'pyslet.html40_19991224.Script'&gt;, ('http://www.w3.org/1999/xhtml', 'center'): &lt;class 'pyslet.html40_19991224.Center'&gt;, ('http://www.w3.org/1999/xhtml', 'q'): &lt;class 'pyslet.html40_19991224.Q'&gt;, ('http://www.w3.org/1999/xhtml', 'cite'): &lt;class 'pyslet.html40_19991224.Cite'&gt;, ('http://www.w3.org/1999/xhtml', 'frame'): &lt;class 'pyslet.html40_19991224.Frame'&gt;, ('http://www.w3.org/1999/xhtml', 'address'): &lt;class 'pyslet.html40_19991224.Address'&gt;, ('http://www.w3.org/1999/xhtml', 'hr'): &lt;class 'pyslet.html40_19991224.HR'&gt;, ('http://www.w3.org/1999/xhtml', 'li'): &lt;class 'pyslet.html40_19991224.LI'&gt;, ('http://www.w3.org/1999/xhtml', 'map'): &lt;class 'pyslet.html40_19991224.Map'&gt;, ('http://www.w3.org/1999/xhtml', 'h4'): &lt;class 'pyslet.html40_19991224.H4'&gt;, ('http://www.w3.org/1999/xhtml', 'td'): &lt;class 'pyslet.html40_19991224.TD'&gt;, ('http://www.w3.org/1999/xhtml', 'table'): &lt;class 'pyslet.html40_19991224.Table'&gt;, ('http://www.w3.org/1999/xhtml', 'span'): &lt;class 'pyslet.html40_19991224.Span'&gt;, ('http://www.w3.org/1999/xhtml', 'ul'): &lt;class 'pyslet.html40_19991224.UL'&gt;, ('http://www.w3.org/1999/xhtml', 'head'): &lt;class 'pyslet.html40_19991224.Head'&gt;, ('http://www.w3.org/1999/xhtml', 'samp'): &lt;class 'pyslet.html40_19991224.Samp'&gt;, ('http://www.w3.org/1999/xhtml', 'tr'): &lt;class 'pyslet.html40_19991224.TR'&gt;, ('http://www.w3.org/1999/xhtml', 'sub'): &lt;class 'pyslet.html40_19991224.Sub'&gt;, ('http://www.w3.org/1999/xhtml', 's'): &lt;class 'pyslet.html40_19991224.S'&gt;, ('http://www.w3.org/1999/xhtml', 'select'): &lt;class 'pyslet.html40_19991224.Select'&gt;, ('http://www.w3.org/1999/xhtml', 'col'): &lt;class 'pyslet.html40_19991224.Col'&gt;, ('http://www.w3.org/1999/xhtml', 'dd'): &lt;class 'pyslet.html40_19991224.DD'&gt;, ('http://www.w3.org/1999/xhtml', 'iframe'): &lt;class 'pyslet.html40_19991224.IFrame'&gt;, ('http://www.w3.org/1999/xhtml', 'abbr'): &lt;class 'pyslet.html40_19991224.Abbr'&gt;, ('http://www.w3.org/1999/xhtml', 'font'): &lt;class 'pyslet.html40_19991224.Font'&gt;, ('http://www.w3.org/1999/xhtml', 'tbody'): &lt;class 'pyslet.html40_19991224.TBody'&gt;, ('http://www.w3.org/1999/xhtml', 'img'): &lt;class 'pyslet.html40_19991224.Img'&gt;, ('http://www.w3.org/1999/xhtml', 'object'): &lt;class 'pyslet.html40_19991224.Object'&gt;, ('http://www.w3.org/1999/xhtml', 'bdo'): &lt;class 'pyslet.html40_19991224.BDO'&gt;, ('http://www.w3.org/1999/xhtml', 'body'): &lt;class 'pyslet.html40_19991224.Body'&gt;, ('http://www.w3.org/1999/xhtml', 'dt'): &lt;class 'pyslet.html40_19991224.DT'&gt;, ('http://www.w3.org/1999/xhtml', 'base'): &lt;class 'pyslet.html40_19991224.Base'&gt;, ('http://www.w3.org/1999/xhtml', 'th'): &lt;class 'pyslet.html40_19991224.TH'&gt;, ('http://www.w3.org/1999/xhtml', 'label'): &lt;class 'pyslet.html40_19991224.Label'&gt;, ('http://www.w3.org/1999/xhtml', 'textarea'): &lt;class 'pyslet.html40_19991224.TextArea'&gt;, ('http://www.w3.org/1999/xhtml', 'dfn'): &lt;class 'pyslet.html40_19991224.Dfn'&gt;, ('http://www.w3.org/1999/xhtml', 'button'): &lt;class 'pyslet.html40_19991224.Button'&gt;, ('http://www.w3.org/1999/xhtml', 'ol'): &lt;class 'pyslet.html40_19991224.OL'&gt;, ('http://www.w3.org/1999/xhtml', 'h5'): &lt;class 'pyslet.html40_19991224.H5'&gt;, ('http://www.w3.org/1999/xhtml', 'link'): &lt;class 'pyslet.html40_19991224.Link'&gt;, ('http://www.w3.org/1999/xhtml', 'pre'): &lt;class 'pyslet.html40_19991224.Pre'&gt;, ('http://www.w3.org/1999/xhtml', 'colgroup'): &lt;class 'pyslet.html40_19991224.ColGroup'&gt;, ('http://www.w3.org/1999/xhtml', 'style'): &lt;class 'pyslet.html40_19991224.Style'&gt;, ('http://www.w3.org/1999/xhtml', 'div'): &lt;class 'pyslet.html40_19991224.Div'&gt;, ('http://www.w3.org/1999/xhtml', 'h6'): &lt;class 'pyslet.html40_19991224.H6'&gt;, ('http://www.w3.org/1999/xhtml', 'i'): &lt;class 'pyslet.html40_19991224.I'&gt;, ('http://www.w3.org/1999/xhtml', 'title'): &lt;class 'pyslet.html40_19991224.Title'&gt;, ('http://www.w3.org/1999/xhtml', 'code'): &lt;class 'pyslet.html40_19991224.Code'&gt;, ('http://www.w3.org/1999/xhtml', 'del'): &lt;class 'pyslet.html40_19991224.Del'&gt;, ('http://www.w3.org/1999/xhtml', 'kbd'): &lt;class 'pyslet.html40_19991224.Kbd'&gt;, ('http://www.w3.org/1999/xhtml', 'html'): &lt;class 'pyslet.html40_19991224.HTML'&gt;, ('http://www.w3.org/1999/xhtml', 'option'): &lt;class 'pyslet.html40_19991224.Option'&gt;, ('http://www.w3.org/1999/xhtml', 'p'): &lt;class 'pyslet.html40_19991224.P'&gt;, ('http://www.w3.org/1999/xhtml', 'h1'): &lt;class 'pyslet.html40_19991224.H1'&gt;, ('http://www.w3.org/1999/xhtml', 'b'): &lt;class 'pyslet.html40_19991224.B'&gt;}</em><a class="headerlink" href="#pyslet.html40_19991224.XHTMLDocument.classMap" title="Permalink to this definition">¶</a></dt>
<dd><p>Data member used to store a mapping from element names to the classes
used to represent them.  This mapping is initialized when the module is
loaded.</p>
</dd></dl>

<dl class="attribute">
<dt id="pyslet.html40_19991224.XHTMLDocument.DefaultNS">
<tt class="descname">DefaultNS</tt><em class="property"> = 'http://www.w3.org/1999/xhtml'</em><a class="headerlink" href="#pyslet.html40_19991224.XHTMLDocument.DefaultNS" title="Permalink to this definition">¶</a></dt>
<dd><p>the default namespace for HTML elements</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.XHTMLDocument.XMLParser">
<tt class="descname">XMLParser</tt><big>(</big><em>entity</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.XHTMLDocument.XMLParser" title="Permalink to this definition">¶</a></dt>
<dd><p>We override the basic XML parser to use a custom parser that is
intelligent about the use of omitted tags, elements defined to have
CDATA content and other SGML-based variations.  Note that if the
document starts with an XML declaration then the normal XML parser is
used instead.</p>
<p>You won&#8217;t normally need to call this method as it is invoked automatically
when you call <tt class="xref py py-meth docutils literal"><span class="pre">pyslet.xml20081126.XMLDocument.Read()</span></tt>.</p>
<p>The result is always a proper element hierarchy rooted in an HTML node,
even if no tags are present at all the parser will construct an HTML
document containing a single Div element to hold the parsed text.</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.XHTMLDocument.GetChildClass">
<tt class="descname">GetChildClass</tt><big>(</big><em>stagClass</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.XHTMLDocument.GetChildClass" title="Permalink to this definition">¶</a></dt>
<dd><p>Always returns HTML.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="basic-types">
<h2>2.5.2. Basic Types<a class="headerlink" href="#basic-types" title="Permalink to this headline">¶</a></h2>
<div class="section" id="length-values">
<h3>2.5.2.1. Length Values<a class="headerlink" href="#length-values" title="Permalink to this headline">¶</a></h3>
<p>Length values are used in many places in HTML, the most common being the width
and height values on images.  There are two ways of specifying a Length, a
simple integer number of pixels or a percentage of some base length defined by
the context (such as the width of the browser window).</p>
<dl class="class">
<dt id="pyslet.html40_19991224.LengthType">
<em class="property">class </em><tt class="descclassname">pyslet.html40_19991224.</tt><tt class="descname">LengthType</tt><big>(</big><em>value</em>, <em>valueType=None</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.LengthType" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Represents the HTML Length:</p>
<div class="highlight-python"><div class="highlight"><pre>&lt;!ENTITY % Length &quot;CDATA&quot; -- nn for pixels or nn% for percentage length --&gt;
</pre></div>
</div>
<ul class="simple">
<li>value can be either an integer value, another LengthType instance or a
string.</li>
<li>if value is an integer then valueType can be used to select Pixel or
Percentage</li>
<li>if value is a string then it is parsed for the length as per the format
defined for length attributes in HTML.</li>
</ul>
<p>By default values are assumed to be Pixel lengths but valueType can be used
to force such a value to be a Percentage if desired.</p>
<dl class="attribute">
<dt id="pyslet.html40_19991224.LengthType.Pixel">
<tt class="descname">Pixel</tt><em class="property"> = 0</em><a class="headerlink" href="#pyslet.html40_19991224.LengthType.Pixel" title="Permalink to this definition">¶</a></dt>
<dd><p>data constant used to indicate pixel co-ordinates</p>
</dd></dl>

<dl class="attribute">
<dt id="pyslet.html40_19991224.LengthType.Percentage">
<tt class="descname">Percentage</tt><em class="property"> = 1</em><a class="headerlink" href="#pyslet.html40_19991224.LengthType.Percentage" title="Permalink to this definition">¶</a></dt>
<dd><p>data constant used to indicate relative (percentage) co-ordinates</p>
</dd></dl>

<dl class="attribute">
<dt id="pyslet.html40_19991224.LengthType.type">
<tt class="descname">type</tt><em class="property"> = None</em><a class="headerlink" href="#pyslet.html40_19991224.LengthType.type" title="Permalink to this definition">¶</a></dt>
<dd><p>type is one of the the LengthType constants: Pixel or Percentage</p>
</dd></dl>

<dl class="attribute">
<dt id="pyslet.html40_19991224.LengthType.value">
<tt class="descname">value</tt><em class="property"> = None</em><a class="headerlink" href="#pyslet.html40_19991224.LengthType.value" title="Permalink to this definition">¶</a></dt>
<dd><p>value is the integer value of the length</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.LengthType.__nonzero__">
<tt class="descname">__nonzero__</tt><big>(</big><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.LengthType.__nonzero__" title="Permalink to this definition">¶</a></dt>
<dd><p>Length values are non-zero if they have a non-zero value (pixel or percentage).</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.LengthType.__str__">
<tt class="descname">__str__</tt><big>(</big><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.LengthType.__str__" title="Permalink to this definition">¶</a></dt>
<dd><p>Formats the length as a string of form nn for pixels or nn% for percentage.</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.LengthType.__unicode__">
<tt class="descname">__unicode__</tt><big>(</big><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.LengthType.__unicode__" title="Permalink to this definition">¶</a></dt>
<dd><p>Formats the length as a unicode string of form nn for pixels or nn% for percentage.</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.LengthType.GetValue">
<tt class="descname">GetValue</tt><big>(</big><em>dim=None</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.LengthType.GetValue" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the value of the Length, <em>dim</em> is the size of the dimension
used for interpreting percentage values.  I.e., 100% will return
<em>dim</em>.</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.LengthType.Add">
<tt class="descname">Add</tt><big>(</big><em>value</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.LengthType.Add" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds <em>value</em> to the length.</p>
<p>If value is another LengthType instance then its value is added to the
value of this instances&#8217; value only if the types match.  If value is an
integer it is assumed to be a value of pixel type - a mismatch raises
ValueError.</p>
</dd></dl>

<dl class="attribute">
<dt id="pyslet.html40_19991224.LengthType.__weakref__">
<tt class="descname">__weakref__</tt><a class="headerlink" href="#pyslet.html40_19991224.LengthType.__weakref__" title="Permalink to this definition">¶</a></dt>
<dd><p>list of weak references to the object (if defined)</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="coordinate-values">
<h3>2.5.2.2. Coordinate Values<a class="headerlink" href="#coordinate-values" title="Permalink to this headline">¶</a></h3>
<p>Coordinate values are simple lists of Lengths.  In most cases Pyslet doesn&#8217;t
define special types for lists of basic types but coordinates are represented in
attribute values using comma separation, not space-separation.  As a result they
require special processing in order to be decoded/encoded correctly from/to XML
streams.</p>
<dl class="class">
<dt id="pyslet.html40_19991224.Coords">
<em class="property">class </em><tt class="descclassname">pyslet.html40_19991224.</tt><tt class="descname">Coords</tt><big>(</big><em>values=None</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.Coords" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents HTML Coords values</p>
<div class="highlight-python"><div class="highlight"><pre>&lt;!ENTITY % Coords &quot;CDATA&quot; -- comma-separated list of lengths --&gt;
</pre></div>
</div>
<p>Instances can be initialized from an existing list of
<a class="reference internal" href="#pyslet.html40_19991224.LengthType" title="pyslet.html40_19991224.LengthType"><tt class="xref py py-class docutils literal"><span class="pre">LengthType</span></tt></a>, or a list of any object that can be used to
construct a LengthType.  It can also be constructed from a string formatted
as per the HTML attribute definition.</p>
<p>The resulting object behaves like a list of LengthType instances, for example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">x</span><span class="o">=</span><span class="n">Coords</span><span class="p">(</span><span class="s">&quot;10, 50, 60%,75%&quot;</span><span class="p">)</span>
<span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">)</span><span class="o">==</span><span class="mi">4</span>
<span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">value</span><span class="o">==</span><span class="mi">10</span>
<span class="n">x</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span><span class="o">.</span><span class="n">type</span><span class="o">==</span><span class="n">LengthType</span><span class="o">.</span><span class="n">Percentage</span>
<span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">3</span><span class="p">])</span><span class="o">==</span><span class="s">&quot;75%&quot;</span>
<span class="c"># items are also assignable...</span>
<span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">=</span><span class="s">&quot;40%&quot;</span>
<span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">type</span><span class="o">==</span><span class="n">LengthType</span><span class="o">.</span><span class="n">Percentage</span>
<span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">value</span><span class="o">==</span><span class="mi">40</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="pyslet.html40_19991224.Coords.values">
<tt class="descname">values</tt><em class="property"> = None</em><a class="headerlink" href="#pyslet.html40_19991224.Coords.values" title="Permalink to this definition">¶</a></dt>
<dd><p>a list of <a class="reference internal" href="#pyslet.html40_19991224.LengthType" title="pyslet.html40_19991224.LengthType"><tt class="xref py py-class docutils literal"><span class="pre">LengthType</span></tt></a> values</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.Coords.__unicode__">
<tt class="descname">__unicode__</tt><big>(</big><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.Coords.__unicode__" title="Permalink to this definition">¶</a></dt>
<dd><p>Formats the Coords as comma-separated unicode string of Length values.</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.Coords.__str__">
<tt class="descname">__str__</tt><big>(</big><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.Coords.__str__" title="Permalink to this definition">¶</a></dt>
<dd><p>Formats the Coords as a comma-separated string of Length values.</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.Coords.TestRect">
<tt class="descname">TestRect</tt><big>(</big><em>x</em>, <em>y</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.Coords.TestRect" title="Permalink to this definition">¶</a></dt>
<dd><p>Tests an x,y point against a rect with these coordinates.</p>
<p>HTML defines the rect co-ordinates as: left-x, top-y, right-x, bottom-y</p>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.Coords.TestCircle">
<tt class="descname">TestCircle</tt><big>(</big><em>x</em>, <em>y</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.Coords.TestCircle" title="Permalink to this definition">¶</a></dt>
<dd><p>Tests an x,y point against a circle with these coordinates.</p>
<p>HTML defines a circle as: center-x, center-y, radius.</p>
<p>The specification adds the following note:</p>
<blockquote>
<div>When the radius value is a percentage value, user agents should
calculate the final radius value based on the associated object&#8217;s
width and height. The radius should be the smaller value of the two.</div></blockquote>
</dd></dl>

<dl class="method">
<dt id="pyslet.html40_19991224.Coords.TestPoly">
<tt class="descname">TestPoly</tt><big>(</big><em>x</em>, <em>y</em>, <em>width</em>, <em>height</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.Coords.TestPoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Tests an x,y point against a poly with these coordinates.</p>
<p>HTML defines a poly as: x1, y1, x2, y2, ..., xN, yN.</p>
<p>The specification adds the following note:</p>
<blockquote>
<div>The first x and y coordinate pair and the last should be the same to
close the polygon. When these coordinate values are not the same,
user agents should infer an additional coordinate pair to close the
polygon.</div></blockquote>
<p>The algorithm used is the &#8220;Ray Casting&#8221; algorithm described here:
<a class="reference external" href="http://en.wikipedia.org/wiki/Point_in_polygon">http://en.wikipedia.org/wiki/Point_in_polygon</a></p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="uris">
<h3>2.5.2.3. URIs<a class="headerlink" href="#uris" title="Permalink to this headline">¶</a></h3>
<p>URIs are represented by instances of the underlying <tt class="xref py py-class docutils literal"><span class="pre">pyselt.rfc2396.URI</span></tt>
class, these functions provide a simple wrapper around the functions defined in
that module.</p>
<dl class="function">
<dt id="pyslet.html40_19991224.DecodeURI">
<tt class="descclassname">pyslet.html40_19991224.</tt><tt class="descname">DecodeURI</tt><big>(</big><em>src</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.DecodeURI" title="Permalink to this definition">¶</a></dt>
<dd><p>Decodes a URI from src:</p>
<div class="highlight-python"><div class="highlight"><pre>&lt;!ENTITY % URI &quot;CDATA&quot;  -- a Uniform Resource Identifier --&gt;
</pre></div>
</div>
<p>Note that we adopt the algorithm recommended in Appendix B of the specification,
which involves replacing non-ASCII characters with percent-encoded UTF-sequences.</p>
<p>For more information see <tt class="xref py py-func docutils literal"><span class="pre">psylet.rfc2396.EncodeUnicodeURI()</span></tt></p>
</dd></dl>

<dl class="function">
<dt id="pyslet.html40_19991224.EncodeURI">
<tt class="descclassname">pyslet.html40_19991224.</tt><tt class="descname">EncodeURI</tt><big>(</big><em>uri</em><big>)</big><a class="headerlink" href="#pyslet.html40_19991224.EncodeURI" title="Permalink to this definition">¶</a></dt>
<dd><p>Encoding a URI means just converting it into a string.</p>
<p>By definition, a URI will only result in ASCII characters that can be freely converted
to Unicode by the default encoding.  However, it does mean that this function doesn&#8217;t
adhere to the principal of using the ASCII encoding only at the latest possible time.</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">2.5. HTML</a><ul>
<li><a class="reference internal" href="#x-html-documents">2.5.1. (X)HTML Documents</a></li>
<li><a class="reference internal" href="#basic-types">2.5.2. Basic Types</a><ul>
<li><a class="reference internal" href="#length-values">2.5.2.1. Length Values</a></li>
<li><a class="reference internal" href="#coordinate-values">2.5.2.2. Coordinate Values</a></li>
<li><a class="reference internal" href="#uris">2.5.2.3. URIs</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="xsdatatypes20041028.html"
                        title="previous chapter">2.4. XML Schema Datatypes</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="rfc2396.html"
                        title="next chapter">2.6. Uniform Resource Identifiers (RFC2396)</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/html40_19991224.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="rfc2396.html" title="2.6. Uniform Resource Identifiers (RFC2396)"
             >next</a> |</li>
        <li class="right" >
          <a href="xsdatatypes20041028.html" title="2.4. XML Schema Datatypes"
             >previous</a> |</li>
        <li><a href="index.html">Pyslet 0.4.20140526 documentation</a> &raquo;</li>
          <li><a href="general.html" >2. Supporting Standards</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright ©2008-2014, Steve Lay.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.1.
    </div>
  </body>
</html>